home *** CD-ROM | disk | FTP | other *** search
/ Symantec Visual Cafe for Java 2.5 / symantec-visual-cafe-2.5-database-dev-edition.iso / Visual Cafe Pro v1.0 / TUTORIAL.BIN / Reserve.class (.txt) < prev    next >
Encoding:
Java Class File  |  1997-02-25  |  10.4 KB  |  382 lines

  1. import java.applet.Applet;
  2. import java.awt.Button;
  3. import java.awt.CardLayout;
  4. import java.awt.Color;
  5. import java.awt.Component;
  6. import java.awt.Container;
  7. import java.awt.Event;
  8. import java.awt.Font;
  9. import java.awt.Label;
  10. import java.awt.LayoutManager;
  11. import java.awt.Panel;
  12. import java.net.MalformedURLException;
  13. import java.net.URL;
  14. import symantec.itools.awt.KeyPressManagerPanel;
  15. import symantec.itools.db.awt.ImageViewer;
  16. import symantec.itools.db.awt.LogonFrame;
  17. import symantec.itools.db.awt.TextArea;
  18. import symantec.itools.db.awt.TextField;
  19. import symantec.itools.db.pro.ConnectionInfo;
  20. import symantec.itools.db.pro.RelationView;
  21. import symantec.itools.db.pro.Request;
  22. import symantec.itools.db.pro.Session;
  23. import symantec.itools.lang.Context;
  24. import symantec.itools.net.RelativeURL;
  25. import symjava.sql.SQLException;
  26.  
  27. public class Reserve extends Applet {
  28.    Session localhost;
  29.    LogonFrame localhostLogonFrame;
  30.    ConnectionInfo Tutorial;
  31.    RelationView DBA_packages;
  32.    RelationView DBA_registration;
  33.    KeyPressManagerPanel keyPressManagerPanel1;
  34.    Button DBA_packages_prev;
  35.    Button DBA_packages_next;
  36.    ImageViewer Image;
  37.    TextField Package_Name;
  38.    Label Package_NameLabel;
  39.    TextArea Description;
  40.    TextField Price_Per_Person;
  41.    Label Price_Per_PersonLabel;
  42.    TextField Number_of_Days;
  43.    Label Number_of_DaysLabel;
  44.    TextField Start_Date;
  45.    Label Start_DateLabel;
  46.    TextField Package_ID;
  47.    Label DescriptionLabel;
  48.    Label Package_IDLabel;
  49.    symantec.itools.multimedia.ImageViewer imageViewerPackage;
  50.    Label Package_IDLabel2;
  51.    Label Customer_Last_NameLabel;
  52.    Label Customer_EmailLabel;
  53.    TextField Package_ID2;
  54.    TextField Customer_First_Name;
  55.    TextField Customer_Last_Name;
  56.    TextField Customer_Email;
  57.    Label Customer_First_NameLabel;
  58.    Label Customer_PhoneLabel;
  59.    Label Number_in_PartyLabel;
  60.    Label Total_CostLabel;
  61.    TextField Customer_Phone;
  62.    TextField Number_in_Party;
  63.    TextField Total_Cost;
  64.    Button DBA_registration_saveMultiView;
  65.    Button DBA_registration_undoRecord;
  66.    symantec.itools.multimedia.ImageViewer imageViewerReg;
  67.  
  68.    void NumberInParty_LostFocus(Event event) {
  69.       this.Total_Cost.setText(String.valueOf(Float.valueOf(this.Price_Per_Person.getText()) * Float.valueOf(this.Number_in_Party.getText())));
  70.    }
  71.  
  72.    void DBARegistrationSaveMultiView_Clicked(Event event) {
  73.       try {
  74.          this.DBA_registration.saveMultiView();
  75.       } catch (SQLException e) {
  76.          System.out.println(((Throwable)e).getMessage());
  77.       }
  78.  
  79.       try {
  80.          this.DBA_registration.getNewRecord();
  81.       } catch (SQLException e) {
  82.          System.out.println(((Throwable)e).getMessage());
  83.       }
  84.  
  85.       this.Package_ID2.setText(this.Package_ID.getText());
  86.    }
  87.  
  88.    void DBARegistrationUndoRecord_Clicked(Event event) {
  89.       try {
  90.          this.DBA_registration.undoRecord();
  91.       } catch (SQLException e) {
  92.          System.out.println(((Throwable)e).getMessage());
  93.       }
  94.  
  95.       this.Package_ID2.setText(this.Package_ID.getText());
  96.    }
  97.  
  98.    void DBARegistrationGetNewRecord_Clicked(Event event) {
  99.       try {
  100.          this.DBA_registration.getNewRecord();
  101.       } catch (SQLException e) {
  102.          System.out.println(((Throwable)e).getMessage());
  103.       }
  104.  
  105.       this.Package_ID2.setText(this.Package_ID.getText());
  106.    }
  107.  
  108.    void DBAPackagesSaveMultiView_Clicked(Event event) {
  109.       try {
  110.          this.DBA_packages.saveMultiView();
  111.       } catch (SQLException e) {
  112.          System.out.println(((Throwable)e).getMessage());
  113.       }
  114.    }
  115.  
  116.    void DBAPackagesPrev_Clicked(Event event) {
  117.       try {
  118.          this.DBA_packages.prev();
  119.       } catch (SQLException e) {
  120.          System.out.println(((Throwable)e).getMessage());
  121.       }
  122.  
  123.       this.Package_ID2.setText(this.Package_ID.getText());
  124.       this.Total_Cost.setText(String.valueOf(Float.valueOf(this.Price_Per_Person.getText()) * Float.valueOf(this.Number_in_Party.getText())));
  125.    }
  126.  
  127.    void DBAPackagesNext_Clicked(Event event) {
  128.       try {
  129.          this.DBA_packages.next();
  130.       } catch (SQLException e) {
  131.          System.out.println(((Throwable)e).getMessage());
  132.       }
  133.  
  134.       this.Package_ID2.setText(this.Package_ID.getText());
  135.       this.Total_Cost.setText(String.valueOf(Float.valueOf(this.Price_Per_Person.getText()) * Float.valueOf(this.Number_in_Party.getText())));
  136.    }
  137.  
  138.    public void init() {
  139.       super.init();
  140.       Context.setDocumentBase(((Applet)this).getDocumentBase());
  141.       ((Container)this).setLayout(new CardLayout(0, 0));
  142.       ((Panel)this).addNotify();
  143.       ((Applet)this).resize(713, 533);
  144.       ((Component)this).setFont(new Font("Dialog", 1, 12));
  145.       ((Component)this).setForeground(new Color(0));
  146.       ((Component)this).setBackground(new Color(16777215));
  147.  
  148.       try {
  149.          this.localhost = new Session("dbaw://localhost:8889");
  150.          this.localhostLogonFrame = new LogonFrame();
  151.          this.localhost.setLogonObject(this.localhostLogonFrame);
  152.       } catch (SQLException e) {
  153.          System.out.println(((Throwable)e).getMessage());
  154.          return;
  155.       }
  156.  
  157.       this.Tutorial = new ConnectionInfo("Tutorial");
  158.       this.Tutorial.setUser("dba");
  159.       this.Tutorial.setPassword("sql");
  160.       this.Tutorial.setAutoDisconnect(false);
  161.  
  162.       try {
  163.          Request DBA_packagesRequest = new Request(this.localhost, this.Tutorial);
  164.          DBA_packagesRequest.setSQL("SELECT Package_ID,Package_Name,Start_Date,Number_of_Days,Price_Per_Person,Image,Description FROM DBA.packages");
  165.          DBA_packagesRequest.setOptimisticConcurrency("All");
  166.          DBA_packagesRequest.setInitialRecordPosition("First");
  167.          this.DBA_packages = new RelationView(DBA_packagesRequest);
  168.          this.DBA_packages.setName("DBA_packages");
  169.       } catch (SQLException e) {
  170.          System.out.println(((Throwable)e).getMessage());
  171.          return;
  172.       }
  173.  
  174.       try {
  175.          Request DBA_registrationRequest = new Request(this.localhost, this.Tutorial);
  176.          DBA_registrationRequest.setSQL("SELECT Package_ID,Customer_First_Name,Customer_Last_Name,Customer_Email,Customer_Phone,Number_in_Party,Total_Cost FROM DBA.registration");
  177.          DBA_registrationRequest.setOptimisticConcurrency("All");
  178.          DBA_registrationRequest.setInitialRecordPosition("New");
  179.          this.DBA_registration = new RelationView(DBA_registrationRequest);
  180.          this.DBA_registration.setName("DBA_registration");
  181.       } catch (SQLException e) {
  182.          System.out.println(((Throwable)e).getMessage());
  183.          return;
  184.       }
  185.  
  186.       this.keyPressManagerPanel1 = new KeyPressManagerPanel();
  187.       this.keyPressManagerPanel1.setLayout((LayoutManager)null);
  188.       this.keyPressManagerPanel1.reshape(0, 0, 713, 533);
  189.       ((Container)this).add(this.keyPressManagerPanel1);
  190.       this.DBA_packages_prev = new Button("Previous");
  191.       this.DBA_packages_prev.reshape(192, 325, 65, 20);
  192.       this.keyPressManagerPanel1.add(this.DBA_packages_prev);
  193.       this.DBA_packages_next = new Button("Next");
  194.       this.DBA_packages_next.reshape(264, 325, 65, 20);
  195.       this.keyPressManagerPanel1.add(this.DBA_packages_next);
  196.       this.Image = new ImageViewer();
  197.       this.Image.setBinding(this.DBA_packages, "Image");
  198.       this.Image.reshape(5, 88, 336, 228);
  199.       this.keyPressManagerPanel1.add(this.Image);
  200.       this.Package_Name = new TextField();
  201.       this.Package_Name.setBinding(this.DBA_packages, "Package_Name");
  202.       this.Package_Name.setDynamicUpdate(false);
  203.       this.Package_Name.setTreatBlankAs("Default");
  204.       this.Package_Name.setEditable(false);
  205.       this.Package_Name.reshape(125, 64, 204, 20);
  206.       this.Package_Name.setBackground(new Color(8421504));
  207.       this.keyPressManagerPanel1.add(this.Package_Name);
  208.       this.Package_NameLabel = new Label("Package Name");
  209.       this.Package_NameLabel.reshape(5, 64, 108, 20);
  210.       this.keyPressManagerPanel1.add(this.Package_NameLabel);
  211.       this.Description = new TextArea();
  212.       this.Description.setBinding(this.DBA_packages, "Description");
  213.       this.Description.setDynamicUpdate(false);
  214.       this.Description.setTreatBlankAs("Default");
  215.       this.Description.setEditable(false);
  216.       this.Description.reshape(365, 184, 276, 120);
  217.       this.Description.setBackground(new Color(8421504));
  218.       this.keyPressManagerPanel1.add(this.Description);
  219.       this.Price_Per_Person = new TextField();
  220.       this.Price_Per_Person.setBinding(this.DBA_packages, "Price_Per_Person");
  221.       this.Price_Per_Person.setDynamicUpdate(false);
  222.       this.Price_Per_Person.setTreatBlankAs("Default");
  223.       this.Price_Per_Person.setEditable(false);
  224.       this.Price_Per_Person.reshape(473, 136, 80, 20);
  225.       this.Price_Per_Person.setBackground(new Color(8421504));
  226.       this.keyPressManagerPanel1.add(this.Price_Per_Person);
  227.       this.Price_Per_PersonLabel = new Label("Price Per Person");
  228.       this.Price_Per_PersonLabel.reshape(353, 136, 120, 20);
  229.       this.keyPressManagerPanel1.add(this.Price_Per_PersonLabel);
  230.       this.Number_of_Days = new TextField();
  231.       this.Number_of_Days.setBinding(this.DBA_packages, "Number_of_Days");
  232.       this.Number_of_Days.setDynamicUpdate(false);
  233.       this.Number_of_Days.setTreatBlankAs("Default");
  234.       this.Number_of_Days.setEditable(false);
  235.       this.Number_of_Days.reshape(473, 112, 80, 20);
  236.       this.Number_of_Days.setBackground(new Color(8421504));
  237.       this.keyPressManagerPanel1.add(this.Number_of_Days);
  238.       this.Number_of_DaysLabel = new Label("Number of Days");
  239.       this.Number_of_DaysLabel.reshape(353, 112, 108, 20);
  240.       this.keyPressManagerPanel1.add(this.Number_of_DaysLabel);
  241.       this.Start_Date = new TextField();
  242.       this.Start_Date.setBinding(this.DBA_packages, "Start_Date");
  243.       this.Start_Date.setDynamicUpdate(false);
  244.       this.Start_Date.setTreatBlankAs("Default");
  245.       this.Start_Date.setEditable(false);
  246.       this.Start_Date.reshape(473, 88, 80, 20);
  247.       this.Start_Date.setBackground(new Color(8421504));
  248.       this.keyPressManagerPanel1.add(this.Start_Date);
  249.       this.Start_DateLabel = new Label("Start Date");
  250.       this.Start_DateLabel.reshape(353, 88, 96, 20);
  251.       this.keyPressManagerPanel1.add(this.Start_DateLabel);
  252.       this.Package_ID = new TextField();
  253.       this.Package_ID.setBinding(this.DBA_packages, "Package_ID");
  254.       this.Package_ID.setDynamicUpdate(false);
  255.       this.Package_ID.setTreatBlankAs("Default");
  256.       this.Package_ID.setEditable(false);
  257.       this.Package_ID.reshape(473, 64, 80, 20);
  258.       this.Package_ID.setBackground(new Color(8421504));
  259.       this.keyPressManagerPanel1.add(this.Package_ID);
  260.       this.DescriptionLabel = new Label("Description");
  261.       this.DescriptionLabel.reshape(353, 160, 108, 20);
  262.       this.keyPressManagerPanel1.add(this.DescriptionLabel);
  263.       this.Package_IDLabel = new Label("Package ID");
  264.       this.Package_IDLabel.reshape(353, 64, 108, 20);
  265.       this.keyPressManagerPanel1.add(this.Package_IDLabel);
  266.       this.imageViewerPackage = new symantec.itools.multimedia.ImageViewer();
  267.       this.imageViewerPackage.reshape(4, 10, 523, 42);
  268.       this.keyPressManagerPanel1.add(this.imageViewerPackage);
  269.       this.imageViewerPackage.setCenterMode(false);
  270.  
  271.       try {
  272.          this.imageViewerPackage.setURL(RelativeURL.getURL("Images/reserv.gif"));
  273.       } catch (MalformedURLException var3) {
  274.       }
  275.  
  276.       this.Package_IDLabel2 = new Label("Package ID");
  277.       this.Package_IDLabel2.reshape(5, 397, 98, 20);
  278.       this.keyPressManagerPanel1.add(this.Package_IDLabel2);
  279.       this.Customer_Last_NameLabel = new Label("Last Name");
  280.       this.Customer_Last_NameLabel.reshape(5, 445, 98, 20);
  281.       this.keyPressManagerPanel1.add(this.Customer_Last_NameLabel);
  282.       this.Customer_EmailLabel = new Label("E-mail");
  283.       this.Customer_EmailLabel.reshape(5, 469, 98, 20);
  284.       this.keyPressManagerPanel1.add(this.Customer_EmailLabel);
  285.       this.Package_ID2 = new TextField();
  286.       this.Package_ID2.setBinding(this.DBA_registration, "Package_ID");
  287.       this.Package_ID2.setDynamicUpdate(false);
  288.       this.Package_ID2.setTreatBlankAs("Default");
  289.       this.Package_ID2.setEditable(false);
  290.       this.Package_ID2.setText("780");
  291.       this.Package_ID2.reshape(113, 397, 80, 20);
  292.       this.Package_ID2.setBackground(new Color(8421504));
  293.       this.keyPressManagerPanel1.add(this.Package_ID2);
  294.       this.Customer_First_Name = new TextField();
  295.       this.Customer_First_Name.setBinding(this.DBA_registration, "Customer_First_Name");
  296.       this.Customer_First_Name.setDynamicUpdate(false);
  297.       this.Customer_First_Name.setTreatBlankAs("Default");
  298.       this.Customer_First_Name.reshape(113, 421, 320, 20);
  299.       this.keyPressManagerPanel1.add(this.Customer_First_Name);
  300.       this.Customer_Last_Name = new TextField();
  301.       this.Customer_Last_Name.setBinding(this.DBA_registration, "Customer_Last_Name");
  302.       this.Customer_Last_Name.setDynamicUpdate(false);
  303.       this.Customer_Last_Name.setTreatBlankAs("Default");
  304.       this.Customer_Last_Name.reshape(113, 445, 320, 20);
  305.       this.keyPressManagerPanel1.add(this.Customer_Last_Name);
  306.       this.Customer_Email = new TextField();
  307.       this.Customer_Email.setBinding(this.DBA_registration, "Customer_Email");
  308.       this.Customer_Email.setDynamicUpdate(false);
  309.       this.Customer_Email.setTreatBlankAs("Default");
  310.       this.Customer_Email.reshape(113, 469, 320, 20);
  311.       this.keyPressManagerPanel1.add(this.Customer_Email);
  312.       this.Customer_First_NameLabel = new Label("First Name");
  313.       this.Customer_First_NameLabel.reshape(5, 421, 98, 20);
  314.       this.keyPressManagerPanel1.add(this.Customer_First_NameLabel);
  315.       this.Customer_PhoneLabel = new Label("Phone");
  316.       this.Customer_PhoneLabel.reshape(437, 397, 98, 20);
  317.       this.keyPressManagerPanel1.add(this.Customer_PhoneLabel);
  318.       this.Number_in_PartyLabel = new Label("Number in Party");
  319.       this.Number_in_PartyLabel.reshape(437, 421, 105, 20);
  320.       this.keyPressManagerPanel1.add(this.Number_in_PartyLabel);
  321.       this.Total_CostLabel = new Label("Total Cost");
  322.       this.Total_CostLabel.reshape(437, 445, 98, 20);
  323.       this.keyPressManagerPanel1.add(this.Total_CostLabel);
  324.       this.Customer_Phone = new TextField();
  325.       this.Customer_Phone.setBinding(this.DBA_registration, "Customer_Phone");
  326.       this.Customer_Phone.setDynamicUpdate(false);
  327.       this.Customer_Phone.setTreatBlankAs("Default");
  328.       this.Customer_Phone.reshape(545, 397, 120, 20);
  329.       this.keyPressManagerPanel1.add(this.Customer_Phone);
  330.       this.Number_in_Party = new TextField();
  331.       this.Number_in_Party.setBinding(this.DBA_registration, "Number_in_Party");
  332.       this.Number_in_Party.setDynamicUpdate(false);
  333.       this.Number_in_Party.setTreatBlankAs("Default");
  334.       this.Number_in_Party.reshape(545, 421, 80, 20);
  335.       this.keyPressManagerPanel1.add(this.Number_in_Party);
  336.       this.Total_Cost = new TextField();
  337.       this.Total_Cost.setBinding(this.DBA_registration, "Total_Cost");
  338.       this.Total_Cost.setDynamicUpdate(false);
  339.       this.Total_Cost.setTreatBlankAs("Default");
  340.       this.Total_Cost.setEditable(false);
  341.       this.Total_Cost.reshape(545, 445, 160, 20);
  342.       this.Total_Cost.setBackground(new Color(8421504));
  343.       this.keyPressManagerPanel1.add(this.Total_Cost);
  344.       this.DBA_registration_saveMultiView = new Button("Send Registration");
  345.       this.DBA_registration_saveMultiView.reshape(311, 505, 120, 20);
  346.       this.keyPressManagerPanel1.add(this.DBA_registration_saveMultiView);
  347.       this.DBA_registration_undoRecord = new Button("Clear");
  348.       this.DBA_registration_undoRecord.reshape(235, 505, 65, 20);
  349.       this.keyPressManagerPanel1.add(this.DBA_registration_undoRecord);
  350.       this.imageViewerReg = new symantec.itools.multimedia.ImageViewer();
  351.       this.imageViewerReg.reshape(4, 357, 536, 32);
  352.       this.keyPressManagerPanel1.add(this.imageViewerReg);
  353.       this.imageViewerReg.setCenterMode(false);
  354.  
  355.       try {
  356.          this.imageViewerReg.setURL(new URL("file:/C:/VisualCafePro/MyApps/AppletDb/Images/register.gif"));
  357.       } catch (MalformedURLException var2) {
  358.       }
  359.    }
  360.  
  361.    public boolean handleEvent(Event event) {
  362.       if (event.target == this.DBA_packages_next && event.id == 1001) {
  363.          this.DBAPackagesNext_Clicked(event);
  364.          return true;
  365.       } else if (event.target == this.DBA_packages_prev && event.id == 1001) {
  366.          this.DBAPackagesPrev_Clicked(event);
  367.          return true;
  368.       } else if (event.target == this.DBA_registration_undoRecord && event.id == 1001) {
  369.          this.DBARegistrationUndoRecord_Clicked(event);
  370.          return true;
  371.       } else if (event.target == this.DBA_registration_saveMultiView && event.id == 1001) {
  372.          this.DBARegistrationSaveMultiView_Clicked(event);
  373.          return true;
  374.       } else if (event.target == this.Number_in_Party && event.id == 1005) {
  375.          this.NumberInParty_LostFocus(event);
  376.          return true;
  377.       } else {
  378.          return super.handleEvent(event);
  379.       }
  380.    }
  381. }
  382.